﻿using AnQinFrameWorkAPI.Entity.SystemCore.DTO.RoleMenu;
using AnQinFrameWorkAPI.Entity.SystemCore.View.RoleMenu;
using AnQinFrameWorkAPI.Service.SystemCore;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.SystemCore;

/// <summary>
///     角色菜单API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "SystemCore")]
public class RoleMenuController : ControllerBase
{
    //业务接口
    private readonly RoleMenuService _roleMenuService;

    //构造注入
    public RoleMenuController(RoleMenuService roleMenuService)
    {
        _roleMenuService = roleMenuService;
    }

    /// <summary>
    ///     获取角色菜单列表
    /// </summary>
    [ProducesResponseType(typeof(RoleMenuView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetRoleMenuList([FromQuery] RoleMenuSearchDTO roleMenuSearchDTO)
    {
        var response = await _roleMenuService.GetRoleMenuList(roleMenuSearchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     启用角色菜单
    /// </summary>
    [HttpPost("EnableMulti")]
    public async Task<IActionResult> EnableRoleMenu([FromBody] RoleMenuUpdateDTO roleMenuUpdateDto)
    {
        var response = await _roleMenuService.EnableMultiRoleMenu(roleMenuUpdateDto);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     禁用角色菜单
    /// </summary>
    [HttpPost("DisableMulti")]
    public async Task<IActionResult> DisableRoleMenu([FromBody] RoleMenuUpdateDTO roleMenuUpdateDto)
    {
        var response = await _roleMenuService.DisableMultiRoleMenu(roleMenuUpdateDto);
        return StatusCode(response.Status, response);
    }
}